/* ========================================================================
 * PROJECT: FTIR Blob Tracker
 * ========================================================================
 * This work is based on the original FTIR Blob Tracker developed by
 *   Woonhyuk Baek
 *   Woontack Woo
 *   U-VR Lab, GIST of Gwangju in Korea.
 *   
 *   http://uvr.gist.ac.kr/
 *
 * Copyright of the derived and new portions of this work
 *     (C) 2009 GIST U-VR Lab.
 *
 * This framework is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation; either version 2 of the License, or
 * (at your option) any later version.
 *
 * This framework is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this framework; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 *
 * For further information please contact 
 *   Woonhyuk Baek
 *   <windage@live.com>
 *   GIST U-VR Lab.
 *   Department of Information and Communication
 *   Gwangju Institute of Science and Technology
 *   1, Oryong-dong, Buk-gu, Gwangju
 *   South Korea
 * ========================================================================
 ** @author   Woonhyuk Baek
 * ======================================================================== */

#ifndef PIPELINING_H
#define PIPELINING_H

#include <vector>
#include <string>
#include <cv.h>

#include "Filter.h"
#include "Smooth.h"
#include "Highpass.h"
#include "Binalize.h"
#include "Dilate.h"

// only gray color image filter pipelining
class Pipelining
{
private:
	std::vector<Filter*> filterList;
	std::vector<IplImage*> temporaryImage;

	// don't create it!
	IplImage* inputImage;
	IplImage* outputImage;

	int width;
	int height;
	int depth;

public:
	Pipelining(int width=DEFAULT_WIDTH, int height=DEFAULT_HEIGHT, int depth=DEFAULT_DEPTH)
	{
		inputImage = NULL;
		outputImage = NULL;

		this->width = width;
		this->height = height;
		this->depth = depth;
	}
	~Pipelining()
	{
		while(this->GetSize())
			this->PopBack();
	}

	std::string GetFilterName(int at);
	Filter* GetFilter(int at);
	
	int PushBack(Filter* filter);
	Filter* PopBack();

	int Do();

	inline int GetSize(){return this->filterList.size();};
	inline void SetInputImage(IplImage* input){this->inputImage = input;};
	inline void SetOutputImage(IplImage* output){this->outputImage = output;};
	inline IplImage* GetInputImage(){return this->inputImage;};
	inline IplImage* GetOutputImage(){return this->outputImage;};

	inline IplImage* GetTemporaryImage(int at)
	{
		if(this->GetSize()-1 <= at)
			return this->outputImage;
		else
			return this->temporaryImage[at];
	}
};

#endif